<?php

/**
 * @author Martin Pernica
 * @copyright 2008
 */

 echo '<h2 class="toggler"><span class="buildLine">Správce menu</span></h2>';
 echo '<div class="element">';

if(empty($_GET['a'])){
echo '<table cellspacing="15" cellpadding="15">';
echo '<tr><td><a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'] .'&mod=menu&a=new"><img src="../libs/icons/add.png" />Nová položka</a></td></tr>';
echo '</table>';

$query = $GLOBALS['db']->query("SELECT * FROM ".$GLOBALS['db_prefix']."menu ORDER BY position DESC") or die($GLOBALS['db']->error);
echo '<table cellspacing="20" cellpadding="30">';
echo '<tr><th>Název</th><th>Odkaz</th><th>Váha</th><th>Pozice</th><th>Akce</th></tr>';
while($data = $query->fetch_array()){
	echo '<tr><td>'.$data['title'].'</td><td>'.$data['href'].'</td><td>'.$data['weigh'].'</td><td>'.$data['position'].'</td><td><a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'].'&mod=menu&a=delete&id='.$data['id'].'"><img src="../libs/icons/delete.png" /></a>&nbsp;&nbsp;<a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'].'&mod=menu&a=edit&id='.$data['id'].'"><img src="../libs/icons/style_edit.png" /></td></tr>';
}
echo '</table></div>';

}else {
	switch($_GET['a']){
		case 'new':
		require 'new.php';
		break;

		case 'delete':
		require 'delete.php';
		break;

		case 'edit':
		require 'edit.php';
		break;
	}
}
?>